from gtkmvc import Controller


class MyControllerProgress(Controller):

    def __init__(self, model, view):
        Controller.__init__(self, model, view)

    def property_progress_value_change(self, model, old, new):
        progressbar = self.view['progressbar']
        if (new is None) or (new.get_total() <= 0):
            # Clear progress bar.
            progressbar.set_text('')
            progressbar.set_fraction(0)
        else:
            progressbar.set_text(new.text_percent())
            progressbar.set_fraction(new.get_fraction())

